	<html>
	<head>
		 	<meta charset="utf-8">	 
	   		 <link href="<?php echo base_url()?>/css/bootstrap.min.css" rel="stylesheet">
	        <!-- PLUGINS CSS -->

	         <link href="<?php echo base_url()?>/plugins/datatable/css/bootstrap.datatable.min.css" rel="stylesheet">
	         <!--  <link href="<?php echo base_url()?>/plugins/formvalidation/formValidation.min.css" rel="stylesheet">-->
	        	        
	        <!-- MAIN CSS (REQUIRED ALL PAGE)-->
	        <link href="<?php echo base_url()?>/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet">
	        <link href="<?php echo base_url()?>/css/style.css" rel="stylesheet">
	        <link href="<?php echo base_url()?>/css/style-responsive.css" rel="stylesheet">
	 	        
	        <!-- MAIN JAVASRCIPT (REQUIRED ALL PAGE)-->
	        <script src="<?php echo base_url()?>/js/jquery.min.js"></script>
	        <script src="<?php echo base_url()?>/js/bootstrap.min.js"></script>
	        
	        <script src="<?php echo base_url()?>/plugins/datatable/js/jquery.dataTables.min.js"></script>
	        <script src="<?php echo base_url()?>/plugins/datatable/js/bootstrap.datatable.js"></script>
	        
	 	   <!--[if lt IE 9]><script src="../excanvas/excanvas.js"></script><![endif]-->		
	</head>
	<body>

		<table class="table table-th-block table-info" style="width:100%">
			<thead>
				<th> Oficina</th>
				<?php 
				$quite = array("Nivel");
				foreach ($categorias as $key) {
					$temp=str_replace($quite, "", $key['categoria']);
					echo "<th with=\"150px \">$temp</th>";
				}?>
				<th> Promedio</th>
			</thead>
			<tbody>
			<?php 
			foreach ($tabla as $k) {
				echo "<tr>
						<td>".ucwords($k['seccion'])."</td>";
						$notas=explode("**",$k['nota']);
						$niveles=explode("**",$k['categoria']);
						
						$avg=0; 
						$index=0;

				for ($i=1; $i <=sizeof($categorias) ; $i++) { 

						if (isset($niveles[$index]) && $i==$niveles[$index]) {
							
							$nota=$notas[$index];
							echo "<td>".$nota."</td>";
							$avg+=$nota;
							$index++;
						} else {
							echo "<td></td>";
						}				
					
				}
				$avg=$avg/$index;
				echo "<td>$avg<td>
						</tr>";
			}

			?>
			</tbody>
		</table>
	</body>
</html>